mod particle;
mod particle_system;

use ggez::{Context, GameResult, GameError, graphics, glam::Vec2};

pub struct State{
    ps: particle_system::PraticleSystem,
}

impl State{
    pub fn new() -> State {
        let origin = Vec2{x: 500.0, y: 300.0};
        let ps = particle_system::PraticleSystem::new(origin);
        State { ps }
    }
}

impl ggez::event::EventHandler<GameError> for State {
    fn update(&mut self, _ctx: &mut Context) -> GameResult {
        self.ps.update();
        Ok(())
    }
    fn draw(&mut self, ctx: &mut Context) -> GameResult {
        let mut canvas = graphics::Canvas::from_frame(ctx, graphics::Color::WHITE);
        self.ps.display(ctx, &mut canvas);
        canvas.finish(ctx)?;
        Ok(())
    }
}